<!DOCTYPE html>
<html>
	<head>
		<meta charset="UTF-8">
		<title>计算圆的周长面积</title>
	</head>
	<body>
		<p>请输入圆的半径</p>
		<input id="n1" type="text">
		<br />
		<br />
		<br />
		<p>
		<input id="butn1" type="button" value="计算圆的周长" onclick="c()"/>
		<input id="butn2" type="button" value="计算圆的面积" onclick="s()"/>
		</p>
		<p id="r"></p>
		<script>
			function c(){
				var num1=document.getElementById("n1");
				var result=document.getElementById("r");
				 if(!Boolean(num1.value.trim())){
				 	alert("您还为输入");
				 	return;
				 }
				if(isNaN(num1.value)){
				 	alert("输入不合法");
				 	return;
				}else{
				 result.innerHTML=Number(num1.value)*2*3.14;
				}
			}
			function s(){
				var num1=document.getElementById("n1");
				var result=document.getElementById("r");
				 if(!Boolean(num1.value.trim())){
				 	alert("您还为输入");
				 	return;
				 }
				if(isNaN(num1.value)){
				 	alert("输入不合法");
				 	return;
				}else{
				 result.innerHTML=Number(num1.value)*Number(num1.value)*3.14;
				}
			}
			
		</script>
	</body>
</html>
